//
//  LBMainController.swift
//  iOSWeibo
//
//  Created by Apple on 16/5/10.
//  Copyright © 2016年 Apple. All rights reserved.
//

import UIKit

class LBMainController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        setupChildViewController()
    }
    ///创建tabbar子控制器
    func setupChildViewController(){
        //抽取方法,设置标题,控件图片,用导航控制起来包装
        let homeVC = HomeVC()
        addChildViewController(homeVC, titileL: "首页", image: "tabbar_home")
        let messageVC = MessageVC()
        addChildViewController(messageVC, titileL: "消息", image: "tabbar_message_center")
        let profileVC = ProfileVC()
        addChildViewController(profileVC, titileL: "我", image: "tabbar_profile")
        let discoverVC = DiscoverVC()
        addChildViewController(discoverVC, titileL: "发现", image: "tabbar_discover")
        
    }
    private  func addChildViewController(childVC:UIViewController,titileL:String,image:String){
        childVC.title = titileL
        childVC.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orangeColor()], forState: UIControlState.Selected)
        childVC.tabBarItem.image = UIImage(named: image)
        childVC.tabBarItem.selectedImage = UIImage(named: (image + "_selected"))?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        addChildViewController(UINavigationController(rootViewController: childVC))
    }
}
